package com.fortune.service.impl;

import com.fortune.dao.COrderDao;
import com.fortune.entity.COrderPolicy;
import com.fortune.service.COrderService;
import com.fortune.vo.cOrder.*;
import com.fortune.vo.wechatProduct.VendorListVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class COrderServiceImpl implements COrderService {
    @Autowired
    private COrderDao cOrderDao;


    @Override
    public List<VendorListVo> findVendorListVoList(String dealerId) {
        return cOrderDao.findVendorListVoList(dealerId);
    }

    @Override
    public String findAcountDid(String dealerId) {
        return cOrderDao.findAcountDid(dealerId);
    }

    /**
     * 查询商品列表
     * @param mid
     * @return
     */
    @Override
    public List<ClientOrderProduct> findListOrderProductInfo(String mid) {
        List<ClientOrderProduct> findListOrderProductInfo = cOrderDao.findListOrderProductInfo(mid);
        return findListOrderProductInfo;
    }

    /**
     * 查询商品优惠
     * @param mid
     * @param mpid
     * @return
     */
    @Override
    public COrderPolicy findListCOrderPolicy(String mid, String mpid) {
        COrderPolicy findListCOrderPolicy = cOrderDao.findListCOrderPolicy(mid, mpid);
        return findListCOrderPolicy;
    }

    /**
     * 生成订单
     * @param did
     * @param clientId
     * @param id
     * @param no
     * @param pTotalPrice
     * @param dTotalPrice
     * @return
     */
    @Override
    public int addCOrder(String did, String clientId, String id, String no, BigDecimal pTotalPrice, BigDecimal dTotalPrice) {
        int addCOrder = cOrderDao.addCOrder(did, clientId, id, no, pTotalPrice, dTotalPrice);
        return addCOrder;
    }

    /**
     * 添加订单详情
     * @param mid
     * @param did
     * @param clientId
     * @param id
     * @param detailsNo
     * @param productId
     * @param orderNum
     * @param price
     * @param policyId
     * @param unitPrice
     * @param backBoxNum
     * @param dprice
     * @param tprice
     * @return
     */
    @Override
    public int addCOrderDetails(String did, String clientId, String id, int detailsNo, String mid, String productId, float orderNum, BigDecimal price, String policyId, BigDecimal unitPrice, float backBoxNum, BigDecimal dprice, BigDecimal tprice) {
        int addCOrderDetails = cOrderDao.addCOrderDetails(did, clientId, id, detailsNo, mid, productId, orderNum, price, policyId, unitPrice, backBoxNum, dprice, tprice);
        return addCOrderDetails;
    }

    /**
     * 添加订单详情-赠送
     * @param mid
     * @param did
     * @param clientId
     * @param id
     * @param detailsNo
     * @param productId
     * @param orderNum
     * @param price
     * @param policyId
     * @param unitPrice
     * @param backBoxNum
     * @param dprice
     * @param tprice
     * @return
     */
    @Override
    public int addCOrderDetailsByZS(String did, String clientId, String id, int detailsNo,String mid,  String productId, float orderNum, BigDecimal price, String policyId, BigDecimal unitPrice, float backBoxNum, BigDecimal dprice, BigDecimal tprice) {
        int addCOrderDetailsByZS = cOrderDao.addCOrderDetailsByZS(did, clientId, id, detailsNo, mid, productId, orderNum, price, policyId, unitPrice, backBoxNum, dprice, tprice);
        return addCOrderDetailsByZS;
    }

    /**
     * 删除订单
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public int editOrder(String did, String clientId, String orderId, BigDecimal pTotalPrice, BigDecimal dTotalPrice) {
        int editOrder = cOrderDao.editOrder(did, clientId, orderId, pTotalPrice, dTotalPrice);
        return editOrder;
    }

    @Override
    public int delOrder(String did, String clientId, String orderId) {
        return cOrderDao.delOrder(did, clientId, orderId);
    }

    /**
     * 查询客户对应的经销商
     * @param clientId
     * @return
     */
    @Override
    public String findClientDid(String clientId) {
        return cOrderDao.findClientDid(clientId);
    }

    /**
     * 订单详情
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetail findClientOrderDetail(String did, String clientId, String orderId) {
        ClientOrderDetail findClientOrderDetail = cOrderDao.findClientOrderDetail(did, clientId, orderId);
        return findClientOrderDetail;
    }

    /**
     * 已出库订单详情
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetail findClientOrderDetailByCk(String did, String clientId, String orderId) {
        ClientOrderDetail findClientOrderDetailByCk = cOrderDao.findClientOrderDetailByCk(did, clientId, orderId);
        return findClientOrderDetailByCk;
    }

    /**
     * 已收货订单详情
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetails findClientOrderDetailsBySH(String did, String clientId, String orderId) {
        ClientOrderDetails findClientOrderDetailsBySH = cOrderDao.findClientOrderDetailsBySH(did, clientId, orderId);
        return findClientOrderDetailsBySH;
    }

    /**
     * 已完成订单详情
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public ClientOrderDetails findClientOrderDetailsByWC(String did, String clientId, String orderId) {
        ClientOrderDetails findClientOrderDetailsByWC = cOrderDao.findClientOrderDetailsByWC(did, clientId, orderId);
        return findClientOrderDetailsByWC;
    }

    /**
     * 删除订单
     * @param did
     * @param clientId
     * @param orderId
     * @return
     */
    @Override
    public int deleteCOrder(String did, String clientId, String orderId) {
        int deleteCOrder = cOrderDao.deleteCOrder(did, clientId, orderId);
        return deleteCOrder;
    }

    /**
     * 查询未处理的列表
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<ClientCOrderDetails> findListClientOrder(String did, String clientId) {
        List<ClientCOrderDetails> findListClientOrder = cOrderDao.findListClientOrder(did, clientId);
        return findListClientOrder;
    }

    /**
     * 查询已批准的列表
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByApproved(String did, String clientId) {
        List<ClientOrder> findListClientOrderByApproved = cOrderDao.findListClientOrderByApproved(did, clientId);
        return findListClientOrderByApproved;
    }

    /**
     * 查询已发货的列表
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByShipped(String did, String clientId) {
        List<ClientOrder> findListClientOrderByShipped = cOrderDao.findListClientOrderByShipped(did, clientId);
        return findListClientOrderByShipped;
    }

    /**
     * 查询已收货
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByreceived(String did, String clientId) {
        List<ClientOrder> findListClientOrderByreceived = cOrderDao.findListClientOrderByreceived(did, clientId);
        return findListClientOrderByreceived;
    }

    /**
     * 查询已完成的列表
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<ClientOrder> findListClientOrderByCompleted(String did, String clientId) {
        List<ClientOrder> findListClientOrderByCompleted = cOrderDao.findListClientOrderByCompleted(did, clientId);
        return findListClientOrderByCompleted;
    }

    /**
     * 商品列表
     * @param mid
     * @return
     */
    @Override
    public List<WorkOrderList> findWorkOrderListList(String mid) {
        List<WorkOrderList> findWorkOrderListList = cOrderDao.findWorkOrderListList(mid);
        return findWorkOrderListList;
    }

    /**
     *  查询订单列表
     * @param did
     * @param clientId
     * @return
     */
    @Override
    public List<DDCOrder> findDDCOrderList(String did, String clientId) {
        return cOrderDao.findDDCOrderList(did, clientId);
    }

    @Override
    public List<DDCOrder> findDDCOrderListByApproved(String did, String clientId) {
        return cOrderDao.findDDCOrderListByApproved(did, clientId);
    }

    @Override
    public List<DDCOrder> findDDCOrderListByShipped(String did, String clientId) {
        return cOrderDao.findDDCOrderListByShipped(did, clientId);
    }

    @Override
    public List<DDCOrder> findDDCOrderListByreceived(String did, String clientId) {
        return cOrderDao.findDDCOrderListByreceived(did, clientId);
    }

    @Override
    public List<DDCOrder> findDDCOrderListByCompleted(String did, String clientId) {
        return cOrderDao.findDDCOrderListByCompleted(did, clientId);
    }

    /**
     * 查询订单详情
     * @param did
     * @param clientId
     * @param cOrderId
     * @return
     */
    @Override
    public List<DDCOrderDetail> findDDCOrderDetailList(String did, String clientId, String cOrderId) {
        return cOrderDao.findDDCOrderDetailList(did, clientId, cOrderId);
    }

    @Override
    public int editClientHFTime(String did, String clientId, String returnPeriod) {
        return cOrderDao.editClientHFTime(did, clientId,returnPeriod);
    }

    @Override
    public String findReturnPeriod(String did, String clientId) {
        return cOrderDao.findReturnPeriod(did, clientId);
    }


}
